<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta charset="UTF-8">
<title>个人中心</title>
<script type="text/javascript" src="../js/jquery.js"></script>
<script src="../js/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../js/bootstrap.js"></script>
<script type="text/javascript" src="../js/Finding.js"></script>
<link rel="stylesheet" href="../css/bootstrap.css" />
<link rel="stylesheet" href="../css/bootstrap.min.css" />
<link rel="stylesheet" href="../css/main.css" />
<script type="text/javascript" src="../js/login.js"></script>
</head>

<body>
	<div class="container">
		<div class="title row">
			<div class="col-md-12">
				<ol class="titlecontent breadcrumb">
					<li><a href="#">徐州工程学院失物招领平台</a></li>
					<li class="active">寻物信息</li>
					<a href="#" id="register" class="login dropdown-toggle disabled"></a>
					<!--
                       	作者：1462859532@qq.com
                       	时间：2017-03-29
                       	描述：
                       	<button class="btn btn-success">成功</button>
                   -->

				</ol>
			</div>
			<div class="col-md-12">
				<div id="myCarousel" class="carousel slide" data-ride="carousel">
					<!-- 轮播（Carousel）指标 -->
					<ol class="carousel-indicators">
						<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
						<li data-target="#myCarousel" data-slide-to="1"></li>
						<li data-target="#myCarousel" data-slide-to="2"></li>
					</ol>
					<!-- 轮播（Carousel）项目 -->
					<div class="carousel-inner">
						<div class="item active">
							<img src="../img/1.jpg" alt="中心校区">
						</div>
						<div class="item">
							<img src="../img/2.jpg" alt="中心校区北门">
						</div>
						<div class="item">
							<img src="../img/3.jpg" alt="图书馆">
						</div>
					</div>
					<!-- 轮播（Carousel）导航 -->
					<a class="carousel-control left" href="#myCarousel"
						data-slide="prev">&lsaquo; </a> <a class="carousel-control right"
						href="#myCarousel" data-slide="next">&rsaquo; </a>
				</div>
			</div>

			<!--
            	作者：1462859532@qq.com
            	时间：2017-03-28
            	描述：导航条
           -->
			<div class="col-md-12">
				<nav class="navbar navbar-default">
				<div class="container-fluid">
					<div class="navbar-header">
						<a class="navbar-brand active" href="main.jsp"><span
							class="glyphicon glyphicon-home" aria-hidden="true"></span>主页</a>
					</div>
					<div class="collapse navbar-collapse"
						id="bs-example-navbar-collapse-1">
						<ul class="nav navbar-nav">
							<li class=""><a href="Losing.jsp"><span
									class="glyphicon glyphicon-pencil" aria-hidden="true"></span>失物信息</a>
							</li>
							<li class=""><a href="Finding.jsp"><span
									class="glyphicon glyphicon-search" aria-hidden="true"></span>寻物信息</a>
							</li>
							<li class=""><a href="Guidence.jsp"><span
									class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span>使用指南</a>
							</li>

						</ul>
					</div>
				</div>
				</nav>
			</div>
			<!--
                	作者：1462859532@qq.com
                	时间：2017-03-29
                	描述：个人发帖纪录
                -->
			<div class="col-md-12">
				<div class="col-md-8">
					<ul id="myTab" class="nav nav-tabs">
						<li class="active"><a href="#losing" data-toggle="tab"> <span
								class="glyphicon glyphicon-pencil" aria-hidden="true"></span>我发过的失物帖子
						</a></li>
						<li><a href="#finding" data-toggle="tab"> <span
								class="glyphicon glyphicon-search" aria-hidden="true"></span>我发过的寻物帖子
						</a></li>

					</ul>
					<div id="myTabContent" class="tab-content">
						<div class="tab-pane fade in active" id="losing">
							<div class="panel panel-default">
								<!-- Default panel contents -->
								<!-- Table -->
								<table class="table table-hover" id="losingitem">

								</table>
								<nav aria-label="Page navigation" style="margin: 0 auto;">
								<ul class="pagination">
									<li id="losingingpagevalue" style="display: none"></li>
									<li id="losingingpagecount" style="display: none"></li>
									<li><a href="#" id="losingfirst">首页</a></li>
									<li><a href="#" id="losingprev">上一页</a></li>
									<li><a href="#" id="losingnext">下一页</a></li>
									<li><a href="#" id="losinglast">尾页</a></li>
								</ul>
								</nav>
							</div>
						</div>
						<div class="tab-pane fade" id="finding">
							<div class="panel panel-default">
								<table class="table table-hover" id="findingitem">

								</table>
								<nav aria-label="Page navigation" style="margin: 0 auto;">
								<ul class="pagination">
									<li id="findingpagevalue" style="display: none"></li>
									<li id="findingpagecount" style="display: none"></li>
									<li><a href="#" id="itemfirst">首页</a></li>
									<li><a href="#" id="itemprev">上一页</a></li>
									<li><a href="#" id="itemnext">下一页</a></li>
									<li><a href="#" id="itemlast">尾页</a></li>
								</ul>
								</nav>
							</div>

						</div>
					</div>

				</div>
				<div class="col-md-4">
					<div class="panel panel-default">
						<div class="panel-heading">与我相关的帖子</div>
						<div class="panel-body" id="myperson"></div>
					</div>
				</div>
			</div>

		</div>
		<div class="container-fluid" style="text-align: center;">
			丁鑫版权所有@copyright</div>

		<!--
				固定在窗口的
			-->
		<div class="active" id="declare">
			<ul>
				<li class="active"><a href="DeatilItem.jsp"><span
						class="glyphicon glyphicon-pencil" aria-hidden="true"></span>我要发帖</a>
				</li>
				<li class=""><a href="#changepassword" data-toggle="modal"><span
						class="glyphicon glyphicon-search" aria-hidden="true"></span>修改密码</a>
				</li>
				<li class=""><a href="#changepersonal" data-toggle="modal"
					id="personinfo"><span class="glyphicon glyphicon-user"
						aria-hidden="true"></span>个人资料</a></li>
				<li class=""><a href="#" data-toggle="modal" id="loseconfig"><span
						class="glyphicon glyphicon-asterisk" aria-hidden="true"></span>信息设置</a>
				</li>
			</ul>
		</div>
		<div>
			<div class="modal fade" id="changepersonal" tabindex="-1"
				role="dialog">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
							<h4 class="modal-title">个人信息</h4>
						</div>
						<div class="modal-body">

							<div class="form-group">
								<!--
                                	作者：1462859532@qq.com
                                	时间：2017-03-28
                                	描述：可以在上面做个表单验证
                                -->
								<label for="inputOld3" class="control-label">姓名</label> <input
									type="text" name="" id="name" class="form-control" value=""
									required="required" placeholder="姓名">
							</div>
							<div class="form-group">
								<label for="inputnewPassword3" class="control-label">手机号码</label>
								<input type="text" class="form-control" id="phone"
									placeholder="手机号码">
							</div>
							<div class="form-group">
								<label for="inputnewsPassword3" class="control-label">电子邮件</label>
								<input type="text" class="form-control" id="email"
									placeholder="电子邮件">
							</div>

						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default"
								data-dismiss="modal">关闭</button>
							<button type="button" class="btn btn-primary" id="btnchangeinfo">保存</button>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!--
        	作者：1462859532@qq.com
        	时间：2017-03-28
        	描述：密码模态框
        -->
		<div>
			<div class="modal fade" id="changepassword" tabindex="-1"
				role="dialog">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
							<h4 class="modal-title">个人信息</h4>
						</div>
						<div class="modal-body">

							<div class="form-group">
								<!--
                                	作者：1462859532@qq.com
                                	时间：2017-03-28
                                	描述：可以在上面做个表单验证
                                -->
								<label for="inputOld3" class="control-label">请输入你的密码</label> <input
									type="password" name="" id="Oldpassword" class="form-control"
									value="" required="required" placeholder="请输入你的旧密码">
							</div>
							<div class="form-group">
								<label for="inputnewPassword3" class="control-label">请输入你的新密码</label>
								<input type="password" class="form-control" id="newPassword"
									placeholder="请输入你的新密码">
							</div>
							<div class="form-group">
								<label for="inputnewsPassword3" class="control-label">请确认你的新密码</label>
								<input type="password" class="form-control"
									id="newsPasswordcopy" placeholder="请确认你的新密码">
							</div>

						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default"
								data-dismiss="modal">关闭</button>
							<button type="button" class="btn btn-primary" id="btnchangepwd">保存</button>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div>
			<div class="modal fade bs-example-modal-lg" tabindex="-1"
				role="dialog" aria-labelledby="myLargeModalLabel" id="changelose">
				<div class="modal-dialog modal-lg" role="document">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
							<h4 class="modal-title">信息设置</h4>
						</div>
						<div class="modal-body">
							<div class="panel-body">
								<table class="losingtable table table-striped"
									cellpadding="20px" cellspacing="5" id="losingshow">
									<thead>
										<tr class="active">
											<th style="width: 25%">物品</th>
											<th style="width: 25%">丢失时间</th>
											<th style="width: 25%">物品描述</th>
											<th style="width: 25%">操作</th>
										</tr>
									</thead>
									<tbody id="locappend">

									</tbody>
								</table>
							</div>
							<div class="panel-footer">
								<div id="pagerole">
									<nav aria-label="Page navigation">
									<ul class="pagination">
										<li id="losepagevalue" style="display: none"></li>
										<li id="losegpagecount" style="display: none"></li>
										<li><a href="#" id="losefirst">首页</a></li>
										<li><a href="#" id="loseprev">上一页</a></li>
										<li><a href="#" id="losenext">下一页</a></li>
										<li><a href="#" id="loselast">尾页</a></li>
									</ul>
									</nav>
								</div>
							</div>

						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default"
								data-dismiss="modal">关闭</button>

						</div>
					</div>
				</div>
			</div>
		</div>
		
			
		<!--模态框关闭-->


		<script type="text/javascript">
				     $(function(){
				       
				    	 $.ajax({
				    		 type:"post",
				    		 url:"../user/relative.action",
				    		 dataType:"json",
				    		 success:function(data){
				    			if(data.length==0){
				    				$("#myperson").append("暂时还没有与你相关的帖子 ");
				    			}else{
				    				
				    				//alert(data.length);
				    				for(var i=0;i<data.length;i=i+2){
				    					//获取个数来进行数据拼接
				    				
				    					for(var j=0;j<data[i].length;j++){
				    					$("#myperson").append("<em>"+data[i][j].itemsDescription+"丢失的帖子</em>");
				    						$("#myperson").append("<div class='col-md-12'><a href='#' style='display:none'>"+data[i][j].pickingID+"</a><div>"+data[i][j].itemlocation+"<a href='#' onclick='forwa(this)'>查看详情</a></div></div>")
				    					$("#myperson").append("<br/>");
				    					}
				    				}
				    			}
				    		 }
				    	 })
				    	 
				    	 $("#loseconfig").click(function(){
				    		 $("#changelose").modal('show');
				    		 $("#locappend").text("");
				    		 $.ajax({
					    		  type:"get",
					    		  url:"../user/queryuserlosing.action",
					    		  dataType:"json",
					    		  success:function(data){
					    			     $("#locappend tr").remove();
					    			  
					    				  if(data.losinginfo.length>=5){
						    				  length=5;
						    			  }else{
						    				  length=data.losinginfo.length;
						    			  }
						    			  for(var i=0;i<length;i++){
						    				  $("#locappend").append('<tr><td style="display: none;">'+
						    						  data.losinginfo[i].losingId+'</td><td>'+
						    						  data.losinginfo[i].categoryName+'</td><td>'+
						    						  data.losinginfo[i].losingTime+'</td><td>'+
						    						  data.losinginfo[i].itemsDescription+'</td><td><button type="button" class="btn btn-primary"  onclick="update(this)">修改</button><button type="button" class="btn btn-primary" id="btnchangepwd" onclick="cancelshow(this)">删除</button></td>');
						    				  
						    				  $("#losepagevalue").text(data.currentpage);
						    			  }
						    			  $("#losegpagecount").text(data.count);
					    			   if(data.losinginfo.length==0){
					    				  $("#locappend").append("你还没有发过任何帖子");
					    			  }	  
					    		  },
					    		  error:function(){
					    			  $("#locappend").append("你还没有发过任何帖子");
					    		  }
					    	  });
				    	 })
				    	 
				    	
				    	 $("#personinfo").click(function(){
				    		 $.ajax({
				    			 type:"post",
				    			 url:"../user/userDetail.action",
				    			 dataType:"json",
				    			 success:function(data){
				    				 $("#name").val(data.userName);
				    				 $("#phone").val(data.phoneNumber);
				    				 $("#email").val(data.email);
				    			 }
				    		 })
				    	 });
				    	
				    	 
				    	 
				    	 
				    	 $.ajax({
				    		  type:"get",
				    		  url:"../user/queryuserlosing.action",
				    		  dataType:"json",
				    		  success:function(data){
				    			  $("#losingitem tr").remove();
				    			  
				    				  if(data.losinginfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.losinginfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				  $("#losingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="losinghelp(this)"><td style="display: none;" >'+
					    						  data.losinginfo[i].losingId+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
					    						  data.losinginfo[i].categoryName+'丢失</td><td style="width: 40%;text-align: right;">'+
					    						  data.losinginfo[i].losingTime+'</td></tr>');
					    				  $("#losingingpagevalue").text(data.currentpage);
					    			  }
					    			  $("#losingingpagecount").text(data.count);
				    			   if(data.losinginfo.length==0){
				    				  $("#losingitem").append("你还没有发过任何帖子");
				    			  }	  
				    		  },
				    		  error:function(){
				    			  $("#losingitem").append("你还没有发过任何帖子");
				    		  }
				    	  });
				    	 
				    	 $.ajax({
				    		  type:"get",
				    		  url:"../user/queryuserpicking.action",
				    		  dataType:"json",
				    		  success:function(data){
				    			  $("#findingitem tr").remove();
				    			  
				    				  var length;
					    			  if(data.pickInfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.pickInfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				  $("#findingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="findinghelp(this)"><td style="display: none;" >'+
					    						  data.pickInfo[i].pickingID+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
					    						  data.pickInfo[i].categoryName+'找到</td><td style="width: 40%;text-align: right;">'+
					    						  data.pickInfo[i].pickerTime+'</td></tr>');
					    				  $("#findingpagevalue").text(data.currentpage);
					    			  }
					    			  $("#findingpagecount").text(data.count); 
				    			  
				    			  if(data.pickInfo.length==0){
				    				  $("#findingitem").append("你还没有发过任何帖子");
				    			  }
				    			  
				    		  },
				              error:function(){
				            	  $("#findingitem").append("你还没有发过任何帖子");
				              }
				    	  });
				    	 
				    	 $("#btnchangepwd").click(function(){
				    		 if($("#newPassword").val()!=$("#newsPasswordcopy").val()){
				    			 alert("确认密码不一致");
				    		 }else{
				    			 $.ajax({
				    				 type:"post",
				    				 url:"../user/changepwd.action",
				    				 dataType:"json",
				    				 data:{"oldpwd":$("#Oldpassword").val(),"newpwd":$("#newPassword").val()},
				    				 success:function(data){
				    					 alert(data);
				    					 $("#changepassword").modal('hide');
				    				 }
				    			 })
				    		 }
				    	 });
				    	 
				    	 $("#btnchangeinfo").click(function(){
				    		 $.ajax({
				    			 type:"post",
				    			 url:"../user/updateuser.action",
				    			 dataType:"json",
				    			 data:{"UserName":$("#name").val(),
				    				 "PhoneNumber":$("#phone").val(),
				    				 "Email":$("#email").val()},
				    		     success:function(data){
				    		    	alert(data);
				    		    	$("#changepersonal").modal("hide");
				    		    	$("#personal").html($("#name").val()+"的个人空间");
				    		     }
				    		 })
				    	 })
				    	 
				    	 
				    	 $("#losingfirst").click(function(){
				    		  $.ajax({
			    				  type:"get",
					    		  url:"../user/queryuserlosing.action?currentpage=0",
					    		  dataType:"json",
					    		  success:function(data){
					    			  $("#losingitem tr").remove();
					    			  if(data.losinginfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.losinginfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				  $("#losingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="losinghelp(this)"><td style="display: none;" >'+
					    						  data.losinginfo[i].losingId+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
					    						  data.losinginfo[i].categoryName+'丢失</td><td style="width: 40%;text-align: right;">'+
					    						  data.losinginfo[i].losingTime+'</td></tr>');
					    				  $("#losingingpagevalue").text(data.currentpage);
					    			  }
					    			  $("#losingingpagecount").text(data.count);
					    		  }
			    			  })
				    	  });
				    	  //上一页
				    	  $("#losingprev").click(function(){
				    		  //alert(123);
				    		  //当前页
				    		  var pagecurrent=$("#losingingpagevalue").text();
				    		  //总页数
				    		  var pagecount=$("#losingingpagecount").text();
				    		  if(pagecurrent==0){
				    			  alert("不好意思，已经是第一页了");
				    		  }
				    		  else{
				    			  $.ajax({
				    				  type:"get",
						    		  url:"../user/queryuserlosing.action?currentpage="+(parseInt(pagecurrent)-1),
						    		  dataType:"json",
						    		  success:function(data){
						    			  $("#losingitem tr").remove();
						    			  if(data.losinginfo.length>=5){
						    				  length=5;
						    			  }else{
						    				  length=data.losinginfo.length;
						    			  }
						    			  for(var i=0;i<length;i++){
						    				  $("#losingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="losinghelp(this)"><td style="display: none;" >'+
						    						  data.losinginfo[i].losingId+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
						    						  data.losinginfo[i].categoryName+'丢失</td><td style="width: 40%;text-align: right;">'+
						    						  data.losinginfo[i].losingTime+'</td></tr>');
						    				  $("#losingingpagevalue").text(data.currentpage);
						    			  }
						    			  $("#losingingpagecount").text(data.count);
						    		  }
				    			  })
				    		  }
				    		 // 
				    	  });
				    	  //下一页
				    	  $("#losingnext").click(function(){
				    		  //当前页
				    		  var pagecurrent=$("#losingingpagevalue").text();
				    		  //总页数
				    		  var pagecount=$("#losingingpagecount").text();
				    		  if((parseInt(pagecurrent)+1)*5>=pagecount){
				    			  alert("不好意思，已经是最后一页了");
				    		  }else{
				    			  $.ajax({
				    				  type:"get",
						    		  url:"../user/queryuserlosing.action?currentpage="+(parseInt(pagecurrent)+1),
						    		  dataType:"json",
						    		  success:function(data){
						    			  $("#losingitem tr").remove();
						    			  if(data.losinginfo.length>=5){
						    				  length=5;
						    			  }else{
						    				  length=data.losinginfo.length;
						    			  }
						    			  for(var i=0;i<length;i++){
						    				  
						    				  $("#losingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="losinghelp(this)"><td style="display: none;" >'+
						    						  data.losinginfo[i].losingId+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
						    						  data.losinginfo[i].categoryName+'丢失</td><td style="width: 40%;text-align: right;">'+
						    						  data.losinginfo[i].losingTime+'</td></tr>');
						    				  $("#losingingpagevalue").text(data.currentpage);
						    			  }
						    			  $("#losingingpagecount").text(data.count);
						    		  }
				    			  })

				    		  }
				    	  });
				    	  //最后一页
				    	  $("#losinglast").click(function(){
				    		  var last;
				    		  if(parseInt($("#losingingpagecount").text())%5!=0){
				    			  last=parseInt(parseInt($("#losingingpagecount").text())/5);
				    		  }else{
				    			  last=parseInt($("#losingingpagecount").text())/5-1;
				    		  }
				    		  $.ajax({
			    				  type:"get",
					    		  url:"../user/queryuserlosing.action?currentpage="+last,
					    		  dataType:"json",
					    		  success:function(data){
					    			  $("#losingitem tr").remove();
					    			  if(data.losinginfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.losinginfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				 
					    				  $("#losingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="losinghelp(this)"><td style="display: none;" >'+
					    						  data.losinginfo[i].losingId+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
					    						  data.losinginfo[i].categoryName+'丢失</td><td style="width: 40%;text-align: right;">'+
					    						  data.losinginfo[i].losingTime+'</td></tr>');
					    				  $("#losingingpagevalue").text(data.currentpage);
					    			  }
					    			  $("#losingingpagecount").text(data.count);
					    		  }
			    			  })
				    	  });
				    	  $("#logout").remove();
				     })
				     
				     function losinghelp(e){
				    	  //alert($(e).children(":first").text());
				    	  var id=$(e).children(":first").text();
				    	 // var categotyappend=$("#categotyappend").find("option:selected").val();
				    	  window.open("../user/ItemInfo.jsp?id="+id+"&type=0");
				      }
				      function findinghelp(e){
				    	  //alert($(e).children(":first").text());
				    	  var id=$(e).children(":first").text();
				    	  window.open("../user/ItemInfo.jsp?id="+id+"&type=1");
				      }
				      
				      $("#itemfirst").click(function(){
				    	  $.ajax({
				    		  type:"get",
				    		  url:"../user/queryuserpicking.action?currentpage=0",
				    		  dataType:"json",
				    		  success:function(data){
				    			  $("#findingitem tr").remove();
				    			  var length;
				    			  if(data.pickInfo.length>=5){
				    				  length=5;
				    			  }else{
				    				  length=data.pickInfo.length;
				    			  }
				    			  for(var i=0;i<length;i++){
				    				  $("#findingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="findinghelp(this)"><td style="display: none;" >'+
				    						  data.pickInfo[i].pickingID+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
				    						  data.pickInfo[i].categoryName+'找到</td><td style="width: 40%;text-align: right;">'+
				    						  data.pickInfo[i].pickerTime+'</td></tr>');
				    				  $("#findingpagevalue").text(data.currentpage);
				    			  }
				    			  $("#findingpagecount").text(data.count);
				    		  }
				    	  });
				      });
				      
				      $("#itemprev").click(function(){
				    	  var pagecurrent=$("#findingpagevalue").text();
			    		  //总页数
			    		  var pagecount=$("#findingpagecount").text();
			    		  if(parseInt(pagecurrent)==0){
			    			  alert("不好意思，已经是第一页了");
			    		  }else{
			    			  $.ajax({
			    				  type:"get",
					    		  url:"../user/queryuserpicking.action?currentpage="+(parseInt(pagecurrent)-1),
					    		  dataType:"json",
					    		  success:function(data){
					    			  $("#findingitem tr").remove();
					    			  var length;
					    			  if(data.pickInfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.pickInfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				  $("#findingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="findinghelp(this)"><td style="display: none;" >'+
					    						  data.pickInfo[i].pickingID+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
					    						  data.pickInfo[i].categoryName+'找到</td><td style="width: 40%;text-align: right;">'+
					    						  data.pickInfo[i].pickerTime+'</td></tr>');
					    				  $("#findingpagevalue").text(data.currentpage);
					    			  }
					    			  $("#findingpagecount").text(data.count);
					    		  }
					    	  });
			    		  }
				    	 
				      });
				      
				      $("#itemnext").click(function(){
				    	  //当前页
			    		  var pagecurrent=$("#findingpagevalue").text();
				    	  //alert(pagecurrent);
			    		  //总页数
			    		  var pagecount=$("#findingpagecount").text();
			    		  //alert(pagecount);
			    		  if((parseInt(pagecurrent)+1)*5>=pagecount){
			    			  alert("不好意思，已经是最后一页了");
			    		  }else{
			    			  $.ajax({
			    				  type:"get",
					    		  url:"../user/queryuserpicking.action?currentpage="+(parseInt(pagecurrent)+1),
					    		  dataType:"json",
					    		  success:function(data){
					    			  $("#findingitem tr").remove();
					    			  if(data.pickInfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.pickInfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				  $("#findingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="findinghelp(this)"><td style="display: none;" >'+
					    						  data.pickInfo[i].pickingID+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
					    						  data.pickInfo[i].categoryName+'找到</td><td style="width: 40%;text-align: right;">'+
					    						  data.pickInfo[i].pickerTime+'</td></tr>');
					    				  $("#findingpagevalue").text(data.currentpage);
					    			  }
					    			  $("#findingpagecount").text(data.count);
					    		  }
			    			  });
			    		  }
				      });
				      
				      $("#itemlast").click(function(){
				    	  var last;
			    		  if(parseInt($("#findingpagecount").text())%5!=0){
			    			  last=parseInt(parseInt($("#findingpagecount").text())/5);
			    		  }else{
			    			  last=parseInt($("#findingpagecount").text())/5-1;
			    		  }
			    		  $.ajax({
		    				  type:"get",
				    		  url:"../user/queryuserpicking.action?currentpage="+last,
				    		  dataType:"json",
				    		  success:function(data){
				    			  $("#findingitem tr").remove();
				    			  if(data.pickInfo.length>=5){
				    				  length=5;
				    			  }else{
				    				  length=data.pickInfo.length;
				    			  }
				    			  for(var i=0;i<length;i++){
				    				 
				    				  $("#findingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="findinghelp(this)"><td style="display: none;" >'+
				    						  data.pickInfo[i].pickingID+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
				    						  data.pickInfo[i].categoryName+'找到</td><td style="width: 40%;text-align: right;">'+
				    						  data.pickInfo[i].pickerTime+'</td></tr>');
				    				  $("#findingpagevalue").text(data.currentpage);
				    			  }
				    			  $("#findingpagecount").text(data.count);
				    		  }
		    			  })
				      })
				      
				      function forwa(e){
				    	  var id=$(e).parent().parent().children(":first").text();
				    	  window.open("../user/ItemInfo.jsp?id="+id+"&type=1");
				      }
				      
				      function cancelshow(e){
				    	var id=$(e).parent().parent().children(":first").text();
				    	$.ajax({
				    		type:"post",
				    		url:"../user/cancelloseitem.action?id="+id,
				    		dataType:"json",
				    		success:function(data){
				    			alert(data);
				    			$(e).parent().parent().remove();
				    		},error:function(){
				    			alert("操作失败");
				    		}
				    	})
				    	
				      }
				      
				      $("#losefirst").click(function(){
				    	  $.ajax({
				    		  type:"get",
				    		  url:"../user/queryuserlosing.action?currentpage=0",
				    		  dataType:"json",
				    		  success:function(data){
				    			  $("#locappend tr").remove();		    			  
			    				  if(data.losinginfo.length>=5){
				    				  length=5;
				    			  }else{
				    				  length=data.losinginfo.length;
				    			  }
				    			  for(var i=0;i<length;i++){
				    				  $("#locappend").append('<tr><td style="display: none;">'+
				    						  data.losinginfo[i].losingId+'</td><td>'+
				    						  data.losinginfo[i].categoryName+'</td><td>'+
				    						  data.losinginfo[i].losingTime+'</td><td>'+
				    						  data.losinginfo[i].itemsDescription+'</td><td><button type="button" class="btn btn-primary"  onclick="update(this)">修改</button><button type="button" class="btn btn-primary" id="btnchangepwd" onclick="cancelshow(this)">删除</button></td>');
				    				  
				    				  $("#losepagevalue").text(data.currentpage);
				    			  }
				    			  $("#losegpagecount").text(data.count);
			    			   if(data.losinginfo.length==0){
			    				  $("#locappend").append("你还没有发过任何帖子");
			    			  }
				    		  }
				    	  });
				      });
				      
				      $("#loseprev").click(function(){
				    	  var pagecurrent=$("#losepagevalue").text();
			    		  //总页数
			    		  var pagecount=$("#losegpagecount").text();
			    		  if(parseInt(pagecurrent)==0){
			    			  alert("不好意思，已经是第一页了");
			    		  }else{
			    			  $.ajax({
			    				  type:"get",
					    		  url:"../user/queryuserlosing.action?currentpage="+(parseInt(pagecurrent)-1),
					    		  dataType:"json",
					    		  success:function(data){
					    			  $("#locappend tr").remove();		    			  
				    				  if(data.losinginfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.losinginfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				  $("#locappend").append('<tr><td style="display: none;">'+
					    						  data.losinginfo[i].losingId+'</td><td>'+
					    						  data.losinginfo[i].categoryName+'</td><td>'+
					    						  data.losinginfo[i].losingTime+'</td><td>'+
					    						  data.losinginfo[i].itemsDescription+'</td><td><button type="button" class="btn btn-primary"  onclick="update(this)">修改</button><button type="button" class="btn btn-primary" id="btnchangepwd" onclick="cancelshow(this)">删除</button></td>');
					    				  
					    				  $("#losepagevalue").text(data.currentpage);
					    			  }
					    			  $("#losegpagecount").text(data.count);
				    			   if(data.losinginfo.length==0){
				    				  $("#locappend").append("你还没有发过任何帖子");
				    			  }
					    		  }
					    	  });
			    		  }
				    	 
				      });
				      
				      $("#losenext").click(function(){
				    	  //当前页
			    		  var pagecurrent=$("#losepagevalue").text();
				    	  //alert(pagecurrent);
			    		  //总页数
			    		  var pagecount=$("#losegpagecount").text();
			    		  //alert(pagecount);
			    		  if((parseInt(pagecurrent)+1)*5>=pagecount){
			    			  alert("不好意思，已经是最后一页了");
			    		  }else{
			    			  $.ajax({
			    				  type:"get",
					    		  url:"../user/queryuserlosing.action?currentpage="+(parseInt(pagecurrent)+1),
					    		  dataType:"json",
					    		  success:function(data){
					    			  $("#locappend tr").remove();		    			  
				    				  if(data.losinginfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.losinginfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				  $("#locappend").append('<tr><td style="display: none;">'+
					    						  data.losinginfo[i].losingId+'</td><td>'+
					    						  data.losinginfo[i].categoryName+'</td><td>'+
					    						  data.losinginfo[i].losingTime+'</td><td>'+
					    						  data.losinginfo[i].itemsDescription+'</td><td><button type="button" class="btn btn-primary"  onclick="update(this)">修改</button><button type="button" class="btn btn-primary" id="btnchangepwd" onclick="cancelshow(this)">删除</button></td>');
					    				  
					    				  $("#losepagevalue").text(data.currentpage);
					    			  }
					    			  $("#losegpagecount").text(data.count);
				    			   if(data.losinginfo.length==0){
				    				  $("#locappend").append("你还没有发过任何帖子");
				    			  }
					    		  }
			    			  });
			    		  }
				      });
				      
				      $("#loselast").click(function(){
				    	  var last;
			    		  if(parseInt($("#losegpagecount").text())%5!=0){
			    			  last=parseInt(parseInt($("#losegpagecount").text())/5);
			    		  }else{
			    			  last=parseInt($("#losegpagecount").text())/5-1;
			    		  }
			    		  $.ajax({
		    				  type:"get",
				    		  url:"../user/queryuserlosing.action?currentpage="+last,
				    		  dataType:"json",
				    		  success:function(data){
				    			  $("#locappend tr").remove();		    			  
			    				  if(data.losinginfo.length>=5){
				    				  length=5;
				    			  }else{
				    				  length=data.losinginfo.length;
				    			  }
				    			  for(var i=0;i<length;i++){
				    				  $("#locappend").append('<tr><td style="display: none;">'+
				    						  data.losinginfo[i].losingId+'</td><td>'+
				    						  data.losinginfo[i].categoryName+'</td><td>'+
				    						  data.losinginfo[i].losingTime+'</td><td>'+
				    						  data.losinginfo[i].itemsDescription+'</td><td><button type="button" class="btn btn-primary"  onclick="update(this)">修改</button><button type="button" class="btn btn-primary" id="btnchangepwd" onclick="cancelshow(this)">删除</button></td>');			  
				    				  $("#losepagevalue").text(data.currentpage);
				    			  }
				    			  $("#losegpagecount").text(data.count);
			    			   if(data.losinginfo.length==0){
			    				  $("#locappend").append("你还没有发过任何帖子");
			    			  }
				    		  }
		    			  })
				      })
				      
				      function update(e){
				    	  var id=$(e).parent().parent().children(":first").text();
				    	  window.open("../user/updateitem.jsp?id="+id);
				    	
				      }
				
				</script>
</body>

</html>